﻿<!--#include file="base.asp"-->
<%
''' SDCMS 分类
''' ==================================================================
''' 版权所有 http://www.sdcms.cn
''' ------------------------------------------------------------------
''' 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
''' 未经授权不允许对程序代码以任何形式任何目的的再发布。
''' ==================================================================
''' 编写: IT平民
''' 修改：IT平民 in 2014.07

	sub adddb()
		dim t0,t1
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
	
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#31867;&#21035;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim data:data=array(array("classname",t0,52),array("ordnum",t1,10),array("followid",followid,10))
		if sdcms.db.dbnew("sd_expand_class",data,"classname='"&t0&"' and followid="&followid&"")=0 then
			sdcms.ajaxjson "&#31867;&#21035;&#21517;&#31216;&#24050;&#23384;&#22312;&#65292;&#35831;&#25442;&#20010;&#35797;&#35797;",0
			exit sub
		else
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub editdb()
		dim t0,t1
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.getint(sdcms.fpost("t1",0),0)
		
		if sdcms.strlen(t0)=0 then sdcms.ajaxjson "&#31867;&#21035;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim data,id
		id=sdcms.getint(sdcms.fget("id",0),0)
		data=array(array("classname",t0,50,1),array("ordnum",t1,10,0))
		if sdcms.db.dbupdate("sd_expand_class","classid="&id&"",data)=1 then
			sdcms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub deldb()
		dim id:id=sdcms.getint(sdcms.fget("id",0),0)
		sdcms.db.dbdel "sd_expand_class","classid="&id
		sdcms.echo "1"
	end sub
	
	sub orderdb()
		dim t0,t1,t2,t3,i
		t0=sdcms.enhtml(sdcms.fpost("cid",0))
		t1=sdcms.enhtml(sdcms.fpost("ordnum",0))
		
		t0=replace(t0," ","")
		t1=replace(t1," ","")
		t2=split(t0,",")
		t3=split(t1,",")
		if ubound(t2)-ubound(t3)<>0 then sdcms.ajaxjson "&#21442;&#25968;&#38169;&#35823;",0:exit sub
		for i=0 to ubound(t2)
			if sdcms.isnum(t2(i)) then
				sdcms.db.dbupdate "sd_expand_class","classid="&t2(i)&"",array(array("ordnum",t3(i),10,0))
			end if
		next
		sdcms.ajaxjson "保存成功",1
	end sub

	islogin
	checkpagelever 16
	dim act:act=lcase(sdcms.fget("act",0))
	dim followid:followid=sdcms.getint(sdcms.fget("followid",0),0)
	dim gourl:gourl=sdcms.fget("gourl",0)
	select case act
		case "add":load eval("theme_expand_class_"&act)
		case "adddb":adddb
		case "edit"
			dim datadb,id
			id=sdcms.getint(sdcms.fget("id",0),0)
			datadb=sdcms.db.dbload("","classname,ordnum","sd_expand_class","classid="&id&"","")
			load eval("theme_expand_class_"&act)
		case "editdb":editdb
		case "del":deldb
		case "order":orderdb
		case else
			load theme_expand_class
	end select
	sdcms.db.dbclose
%>
